/************************************************************************** 
 * @name: None
 * @brief: None
 * @date: 
 * @author: boluzs@163.com
 * @note: None
 * @version: 1.0.0
 * @Copyright (c) 2025 by boluzs@163.com, All Rights Reserved. 
 **************************************************************************/
/**************************************************************************
 * @name:  002_OpenFileMax.c
 * @brief: 这是用于计算open最多可以打开多少个文件代码案例
 * @date:  2025/01/06
 * @author: boluzs@163.com
 * @note:
 * @version: 1.0.0
 * @Copyright (c) 2025 by boluzs@163.com, All Rights Reserved.
 **************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main(int argc, char const *argv[])
{
    int max = 0;
    // 1.利用open函数追加模式打开一个文件
    for (;;)
    {
        int fd = open("./a.txt", O_RDWR);
        if (-1 == fd)
        {
            // fprintf(stderr, "open error, errno= %d,%s!\n", errno, strerror(errno));
            break;
        }
        max++;
    }
    printf("打开文件最大数是：%d\n", max);
    return 0;
}
